package mobmap;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.midlet.MIDlet;

import mobmap.info.Informacoes;
import mobmap.splash.SplashScreen;
import mobmap.tela.MapCanvas;

public class MainMap extends MIDlet implements CommandListener {
	
	MapCanvas mapCanvas;
	Command sair = new Command("Sair", Command.EXIT, 3);
	Command sobre = new Command("Sobre", Command.SCREEN, 2);
	Command miniMap = new Command("Visão Geral", Command.SCREEN, 2);

	Display display;

	public void startApp() {
		
		mapCanvas = new MapCanvas();
		mapCanvas.addCommand(sair);
		mapCanvas.addCommand(sobre);
		mapCanvas.addCommand(miniMap);
		
		mapCanvas.setCommandListener(this);
		mapCanvas.setFullScreenMode(true);

		display = Display.getDisplay(this);
		new SplashScreen(display, mapCanvas);

	}

	public void pauseApp() {
	}

	public void destroyApp(boolean bl) {
		notifyDestroyed();
	}

	public void commandAction(Command comando, Displayable displayable) {

		if (comando == sair) {
			destroyApp(true);
		}else if(comando == sobre){
			Informacoes informacoes = new Informacoes("Sobre", displayable, this);
			Display.getDisplay(this).setCurrent(informacoes);
		}else if (comando == miniMap){
			mapCanvas.setEnableMiniMap(!mapCanvas.isEnableMiniMap());
		}
		
	}

}

